import request from "@/util/httpUtils";

// eslint-disable-next-line no-unused-vars
function getCookie (name) {
  for (var s of document.cookie.split(";")) {
    var arr = s.split("=");
    if(arr[0].trim() == name){
      return arr[1];
    }
  }
  return "NONE";
}

// const temptoken = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwicGFzc3dvcmQiOiJhdHcxd29uem5jbjhMeHM0NlRfNVBDLTlNdkEiLCJpZCI6MSwiZXhwIjoxNjM5ODkxODEyLCJpYXQiOjE2MjQzMzk4MTIsImp0aSI6ImQ5Njc5ODc3LTM5YWYtNDRhOC1hY2Y4LWZlNzFjNTJlMzFkNyIsInVzZXJuYW1lIjoi5paw5pawIn0.QhkVRbCPAEincUbSgGnM8ml7x75NXZA_Sa0z5dx4st4";

// const temptoken = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMDEyIiwicGFzc3dvcmQiOiIxMjM0NTYiLCJpZCI6MTAxMiwiZXhwIjoxNjM4ODEwNTUwLCJpYXQiOjE2MjMyNTg1NTAsImp0aSI6IjUwN2Y1YTFlLWY0M2ItNDNlNC1hY2UzLTMzMDk1M2JhYmI3YSIsInVzZXJuYW1lIjoi6JKL5bu65by6In0.EjTMiuRWIAOst98UWCA88c_WvXkQY0Q1iC_BcqJ_dns";
//陈天宏
// const temptoken = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMDEzIiwicGFzc3dvcmQiOiIxMjM0NTYiLCJpZCI6MTAxMywiZXhwIjoxNjM4ODEwNTkyLCJpYXQiOjE2MjMyNTg1OTIsImp0aSI6ImEyZTFkMjNkLWNhMjktNDUyYi05NWQxLTRlZDdiMmJlYmNlYyIsInVzZXJuYW1lIjoi6ZmI5aSp5a6PIn0.u7CeMmdfrTEZX5GIxPCkW-UIDtXQBES-EgD8E-BSy0U";
//齐启欢
// const temptoken = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI5MzUiLCJwYXNzd29yZCI6IjEyMzQ1NiIsImlkIjo5MzUsImV4cCI6MTY0MDAwODcwNCwiaWF0IjoxNjI0NDU2NzA0LCJqdGkiOiJlZTNiMzhmNS02M2U3LTQzYTgtYmFhYi03NDU2YjFiYTI4MDQiLCJ1c2VybmFtZSI6Ium9kOWFtuasoiJ9.2SenXmkm935gYKLU4kUS8GVpVBQyYbRK3u_U03r_zk4";
//唐海月
const temptoken = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI5OTIiLCJwYXNzd29yZCI6IjEyMzQ1NiIsImlkIjo5OTIsImV4cCI6MTYzOTU1NTQ4MSwiaWF0IjoxNjI0MDAzNDgxLCJqdGkiOiIwMzgyMjNiZS01OTZjLTQ1ZmEtOWIzOS01NTI2NDdkYmM3NTQiLCJ1c2VybmFtZSI6IuWUkOa1t-aciCJ9.iMNo2BRYNPHGNZV2D84unORXvquXH8rOaVlUOHnCMsI";
// const temptoken = getCookie('token');

export default {
    get(url, params) {
        const urlPath = this.api[url];
        
        // const token = getCookie('token') 
        const token = temptoken;
        const header = token
            ? {
                  token: token
            }
            : null;
        return request({
            url: urlPath,
            method: "get",
            headers: header,
            params,
        });
    },
    post(url, data) {
        const urlPath = this.api[url];
        // const token = getCookie('token') 
        const token = temptoken;
        const header = 
         {
            token: token
        }
        ;
        
        return request({
            url: urlPath,
            method: "post",
            headers: header,
            data,
        });
    },
    uploadFileByFormData(data) {
        // const token = getCookie('token') 
        const token = temptoken; 
        const header = {
            //   Authorization: "Bearer " + token,
            token: token,
                // token ||
                "Content-Type": "multipart/form-data",
        };
        const formdata = new FormData();
        formdata.append("file", data);
        return request({
            url: this.api["上传资源"],
            method: "post",
            headers: header,
            data: formdata,
        });
    },
    api: {
        //部门
        返回用户所在的部门和全部门列表:"/gw-user/system/login/management/selectDeptList",
        返回指定部门中所有用户列表:"/gw-user/system/login/management/selectUserListByDeptId",
        返回用户所在的小组和全小组列表:"/gw-user/system/login/management/selectTeamList",
        返回指定小组中所有用户列表:"/gw-user/system/login/management/selectUserListByTeamId",

        /**
         * 任务
         */
        查询任务列表:"/gw-leifeng/task/selectTaskList",
        提交新任务:"/gw-leifeng/task/submitNewTask",
        我发布的任务列表:"/gw-leifeng/task/myBuildTaskList",
        我接单的任务列表:"/gw-leifeng/task/myReceiveTaskList",
        设置接单任务状态:"/gw-leifeng/task/updateTaskStatus",
        任务详情:"/gw-leifeng/task/taskDetail",
        接单任务:"/gw-leifeng/task/receiveTask",
        /**
         * 月报
         */
        加入月报:"/gw-leifeng/monthReport/joinMonthReport",
        月报详情:"/gw-leifeng/monthReport/monthReportDetail",
        /**
         * y
         */
        上传资源:"/gw-leifeng/resource/uploadResource",
        查询任务大厅中各种任务的数量:"/gw-leifeng/task/getAllTaskNumMap",
        查询我的接单页面中各种任务的数量:"/gw-leifeng/task/getAcceptTaskNumMap",
        查询我发布的任务历史提醒的人和记录:"/gw-leifeng/task/selectTaskHistoryTipList",
        删除历史提醒:"/gw-leifeng/task/deleteTaskHistoryTip",
        
        /**
         * 发布人
         */
         发布人关闭任务: "/gw-leifeng/task/closeTask",
         发布人采纳接单人完成成果: "/gw-leifeng/task/adoptTaskAccept",
        /**
         * 接单人
         */
         接单人取消接单任务:"/gw-leifeng/task/cancelTaskAccept",
        //  API http://yapi.365diaocha.com/project/24/interface/api/191
         接单人完成接单任务:"/gw-leifeng/task/finishTaskAccept",
         
        /**
          * 用户
          */

         "userInfo":"/gw-user/system/login/management/userInfo",
         "getTeamSummaryByUserId":"/gw-user/system/login/management/getTeamSummaryByUserId",
         "getMyTeamSummary":"/gw-user/system/login/management/getMyTeamSummary",

         /**
          * 组员互评
          */
         
         "addTeamInnerSelfComment":"/gw-leifeng/comment/addTeamInnerSelfComment",
         "addTeamInnerOtherComment":"/gw-leifeng/comment/addTeamInnerOtherComment",
         "addTeamInnerRepeatComment":"/gw-leifeng/comment/addTeamInnerRepeatComment",
         "selectTeamInnerSelfCommentList":"/gw-leifeng/comment/selectTeamInnerSelfCommentList",
         "commentDetail":"/gw-leifeng/comment/commentDetail",
         "getRemainDuring":"/gw-leifeng/comment/getRemainDuring",
         "getMonthList":"/gw-leifeng/comment/getMonthList",
         "isCanComment":"/gw-leifeng/comment/isCanComment",
         /**
          * 小组奖金
          */
        "isCanApplyTeamBonus":"/gw-leifeng/bonus/isCanApplyTeamBonus",
        "getTeamId":"/gw-leifeng/bonus/getTeamId",
        "applyTeamBonus":"/gw-leifeng/bonus/applyTeamBonus",
        "everyoneReviewTeamBonus":"/gw-leifeng/bonus/everyoneReviewTeamBonus",
        "teamApplyBonusList":"/gw-leifeng/bonus/teamApplyBonusList",
        "teamApplyDetail":"/gw-leifeng/bonus/teamApplyDetail",
    },
};
